package com.googlecode.wheres_my_stuff_okay_potato;

/**
 * This class is a subclass of User, and it is simply a user with administrator
 * privileges such as locking accounts.
 * 
 * @author Chad Miller
 */
public class Admin extends User {
	private static final long serialVersionUID = 2726566667454236356L;

	/**
	 * Creates an instance of Admin. This constructor simply calls its
	 * superconstructor through User.
	 * 
	 * @param username
	 *            is the username of the admin.
	 * @param password
	 *            is the password of the admin.
	 * @param email
	 *            is the email address of the admin.
	 */
	public Admin(String username, String password, String email) {
		super(username, password, email);
	}

	/**
	 * Locks a user out of the system.
	 * 
	 * @param user
	 *            is the user to lock.
	 * @return returns true if the user's account has been successfully locked;
	 *         false otherwise.
	 */
	protected boolean lockUser(User user) {
		return user.lock();
	}

	/**
	 * Overrides User.lock() because Admins cannot be locked out of the system.
	 * This returns false every time.
	 * 
	 * @return false every time.
	 */
	@Override
	public boolean lock() {
		return false;
	}

	/**
	 * Unlocks a user that is locked out.
	 * 
	 * @param user
	 *            is the user to be unlocked.
	 */
	protected void unlockUser(User user) {
		user.unlock();
	}

	/**
	 * Overrides User.isAdmin() to return true.
	 * 
	 * @return true every time.
	 */
	@Override
	public boolean isAdmin() {
		return true;
	}
}